package controllers;

import java.util.Set;

import models.Usuario;
import play.data.Form;
import play.mvc.Controller;
import play.mvc.Result;
import views.html.*;
import dao.DAOUsuario;

public class Application extends Controller {


	public static Result index() {
		return ok(views.html.index.render(""));
	}


	public static Result logout() {
		session().clear();
		
		return ok(views.html.index.render(""));
	}
	
	
	public static Result home() {
		Usuario usu = null;
		try {
			usu = (new DAOUsuario()).select(Integer.parseInt(session("usuario_id")));
			
			switch (usu.idPerfil) {
				case 1: {return ok(views.html.usuario.homeAtendente.render(usu));}
				case 2: {return ok(views.html.usuario.homeProfessor.render(usu));}
				case 3: {return ok(views.html.usuario.homeAluno.render(usu));}
			}
			
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return ok(views.html.index.render(""));
	}
	
}
